﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using BOMS.DBUtility;
using System.Xml;
using System.Configuration;

namespace BOMS.DAL
{
   public class DALUti
    {
         public static DataSet GetPageData(string sql, string orderby, int pageSize, int curPage, out int recordCount)
            {
                SqlParameter[] parms = new SqlParameter[5];
                (parms[0] = new SqlParameter("@sqlStr", SqlDbType.NVarChar, -1)).Value = sql;
                (parms[1] = new SqlParameter("@orderbyStr", SqlDbType.NVarChar, 30)).Value = orderby;
                (parms[2] = new SqlParameter("@pagesize", SqlDbType.Int)).Value = pageSize;
                (parms[3] = new SqlParameter("@curPage", SqlDbType.Int)).Value = curPage;
                (parms[4] = new SqlParameter("@rowcount", SqlDbType.Int)).Direction = ParameterDirection.Output;
                DataSet ds = DbHelperSQL.RunProcedure("dbo.sp_FreePager", parms, "FPGOUT");
                recordCount = (int)parms[4].Value;
                return ds;
            }
         public static string ImportEquipData(string ip, string mac, DateTime dtm, string xml)
         {    
             /*
             SqlParameter[] parms = new SqlParameter[4];
             (parms[0] = new SqlParameter("@Mac", SqlDbType.NVarChar, 40)).Value = mac;
             (parms[1] = new SqlParameter("@IP", SqlDbType.NVarChar, 40)).Value = ip;
             (parms[2] = new SqlParameter("@dtm", SqlDbType.DateTime)).Value = dtm;
             (parms[3] = new SqlParameter("@xmldata", SqlDbType.NVarChar, -1)).Value = xml;
             SqlDataReader dr = DbHelperSQL.RunProcedure("sp_sub_LoadLogData", parms);
             dr.Dispose();
             dr.Close();
             return "OK";*/
             ImportDataDAL du = new ImportDataDAL();
             return du.ImportEquipDataFromXML(ip, mac, dtm, xml);
         }
        
    }
}
